package xyz.thoughtset.viewer.common.core.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import xyz.thoughtset.viewer.common.core.constants.StatusCodeConstant;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseMeta extends TitleMeta{
    @OrderBy(asc = true,sort = 0)
    protected Integer orderNum;
    @TableField(fill = FieldFill.INSERT_UPDATE)
    protected Integer statesCode = 200;


    @SneakyThrows
    public static <T extends BaseMeta> T buildByOrder(String id, Integer orderNum, Class<T> clazz){
        T baseObj = clazz.getDeclaredConstructor().newInstance();
        baseObj.setId(id);
        baseObj.setOrderNum(orderNum);
        return baseObj;
    }

}
